#include "PhotoTool.h"

PhotoTool::PhotoTool()
{
	mp_capture = NULL;
}

PhotoTool::~PhotoTool()
{
	if (mp_capture != NULL)
	{
		mp_capture->release();
	}
}

bool PhotoTool::init(YLog* l)
{
	mp_log = l;
	mp_capture = new VideoCapture(0);

	if (!mp_capture->isOpened())
	{
		mp_capture->release();
		mp_capture = NULL;
		return false;
	}

	return true;
}

bool PhotoTool::getPhoto(Mat& out)
{
	if (!mp_capture->read(out))
	{
		mp_log->w(__FILE__, __LINE__, YLog::INFO, "getPhoto", "read photo is error");
		return false;
	}

	return true;
}